package com.zhang.use;
import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.core.AppenderBase;
import ch.qos.logback.core.encoder.Encoder;
import java.io.UnsupportedEncodingException;


public class MyAppender extends AppenderBase<ILoggingEvent> {
    private Encoder<ILoggingEvent> encoder;

    public void setEncoder(Encoder<ILoggingEvent> encoder) {
        this.encoder = encoder;
    }

    @Override
    protected void append(ILoggingEvent e) {
        byte[] byteArray = this.encoder.encode(e);
        try {
            String s = new String(byteArray, "utf-8");
            System.out.println(s);
        } catch (UnsupportedEncodingException ex) {
            ex.printStackTrace();
        }

    }
}
